package com.telecomyt.jwportal.activity.conversation.adapter;

import android.provider.CallLog;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.telecomyt.jwportal.R;
import com.telecomyt.jwportal.activity.conversation.bean.CallInfoBean;

import java.text.SimpleDateFormat;

/**
 * @author created by chengDa
 * @time 2020/9/9  11:05
 * @description
 */
public class ConversationStatusAdapter extends BaseQuickAdapter<CallInfoBean, BaseViewHolder> {
    public ConversationStatusAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, CallInfoBean item) {
        if (TextUtils.isEmpty(item.getName())) {
            helper.setText(R.id.mTvNumber, item.getNumber());
        } else {
            helper.setText(R.id.mTvNumber, item.getName());
        }
        SimpleDateFormat format = new SimpleDateFormat(
                "yyyy-MM-dd hh:mm:ss");
        String dateStr = format.format(item.date);
        switch (item.getType()) {
            case CallLog.Calls.INCOMING_TYPE:
                //"打入"
                helper.setText(R.id.mTvStutas, String.format("%s  %s", "呼入[普通电话]", dateStr));
                break;
            case CallLog.Calls.OUTGOING_TYPE:
                //"打出"
                helper.setText(R.id.mTvStutas, String.format("%s  %s", "呼出[普通电话]", dateStr));
                break;
            case CallLog.Calls.MISSED_TYPE:
                //"未接"
                helper.setText(R.id.mTvStutas, String.format("%s  %s", "未接电话[普通电话]", dateStr));
                break;
            default:
                break;
        }

    }
}
